package top.lyunz.lucky.hr.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import top.lyunz.lucky.hr.bean.Mhselect;
import top.lyunz.lucky.hr.bean.SalaryStandard;
import top.lyunz.lucky.hr.service.Salary_standardService;

@Controller
@RequestMapping("/salary")
public class salaryController {
	
	@Resource
	private Salary_standardService salary_standardService;
	
	@RequestMapping("/salaryRe")
	public String salaryRe() {
		return "/page/salaryCriterion/salarystandard_register";
	}
	
	@RequestMapping("/add")
	public String add(SalaryStandard ssd) {
		boolean add = salary_standardService.add(ssd);
		if (add == true) {
			return "redirect:/salary/toSalaryre";
		} else {
			return "redirect:/salary/toSalaryre";
		}
	}
	
	@RequestMapping("/toReview")
	public String getAll(Model model,HttpSession session) {
		List<SalaryStandard> ss = salary_standardService.getall();
		int sss = ss.size();
		model.addAttribute("ss", ss);
		session.setAttribute("sss", sss);
		
		return "/page/salaryCriterion/salarystandard_check_list";
	}
	
	@RequestMapping("/salaryQuery")
	public String salaryQuery() {
		return "/page/salaryCriterion/salarystandard_query_locate";
	}
	
	@RequestMapping("/mhSel") 
	public String salaryMh(Model model, Mhselect ms,HttpSession session) {
		List<SalaryStandard> s = salary_standardService.Mhsel(ms);
		int a = s.size();
		model.addAttribute("s",s);
		session.setAttribute("a", a);
		return "/page/salaryCriterion/salarystandard_query_list";
	}
	
	@RequestMapping("/salaryChange")
	public String salaryChange() {
		return "/page/salaryCriterion/salarystandard_change_locate";
	}
	
	@RequestMapping("/mhSels") 
	public String salaryMhs(Model model, Mhselect sa,HttpSession session) {
		List<SalaryStandard> bb = salary_standardService.Mhsels(sa);
		int b = bb.size();
		model.addAttribute("bb",bb);
		session.setAttribute("b", b);
		return "/page/salaryCriterion/salarystandard_change_list";
	}
	
	@RequestMapping("/toSalaryre")
	public String toSalaryre() {
		return "/page/salaryCriterion/salarystandard_register_success";
	}
	
	@RequestMapping("goReview/{ssdId}")
	public String goReview(@PathVariable("ssdId") int ssdId,Model model) {
		SalaryStandard standard = salary_standardService.GetByid(ssdId);
		model.addAttribute("standard", standard);
		return "/page/salaryCriterion/salarystandard_check";
	}
	
	@RequestMapping("/successReview")
	public String upd(SalaryStandard ss) {
		boolean upd = salary_standardService.upd(ss);
		if (upd == true) {
		return "/page/salaryCriterion/salarystandard_check_success";
		}else {
		return "/page/salaryCriterion/salarystandard_check";
		}
	}
	
	@RequestMapping("/goSalaryquery")
	public String goSalaryquery() {
		return "/page/salaryCriterion/salarystandard_query_list";
	}
	
	@RequestMapping("/toSalaryquery")
	public String toSalaryquery() {
		return "/page/salaryCriterion/salarystandard_query";
	}
	
	@RequestMapping("/toSalarychange")
	public String toSalarychange() {
		return "/page/salaryCriterion/salarystandard_change";
	}
	
	@RequestMapping("/agSalarychange")
	public String agSalarychange() {
		return "/page/salaryCriterion/salarystandard_change_success";
	}
	
}
